﻿CREATE TRIGGER [tr_Loan_Menus_Insert]
ON [dbo].[t_Loan_Menus] 
FOR INSERT
AS

IF NOT @@ROWCOUNT BETWEEN 1 AND 1000 RETURN

DECLARE cur CURSOR LOCAL FOR
SELECT LoanID, MenuID, MenuPrevID FROM inserted

OPEN cur

DECLARE @LoanID sysname,@MenuID sysname, @MenuPrevID sysname
FETCH NEXT FROM cur INTO @LoanID,@MenuID,@MenuPrevID

WHILE @@FETCH_STATUS = 0 BEGIN
	--PRINT dbo.sprint4('@ObjectName:%s,@Key_1:%s,@FromID:%s,@ToID:%s',@ObjectName,@Key_1,@FromID,@ToID)
	EXEC smenu__Action @LoanID,@MenuPrevID,@MenuID
	IF @@ERROR <> 0 BEGIN ROLLBACK TRAN RETURN END
	FETCH NEXT FROM cur INTO @LoanID,@MenuID,@MenuPrevID
END

RETURN

